package com.example.mobifin_busticket.views.dialogs;

import com.example.mobifin_busticket.R;
import com.example.mobifin_busticket.views.activities.CancelTicketDetailsActivity;
import com.example.mobifin_busticket.views.activities.TicketBookingSummaryScreen;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;

public class PrintTicketDialog extends Dialog implements
		android.view.View.OnClickListener {
	Button btn_ok, btn_cncle;
	EditText etTicketNo;
	Context context;

	public PrintTicketDialog(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.print_ticket_dialog);
		etTicketNo = (EditText) findViewById(R.id.etTicketNo);
		btn_ok=(Button)findViewById(R.id.btn_Pok);
		btn_cncle = (Button) findViewById(R.id.btn_cncl_in_pdialog);
		btn_ok.setOnClickListener(this);
		btn_cncle.setOnClickListener(this);
		this.context = context;
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.btn_cncl_in_pdialog:
			dismiss();
			break;
		case R.id.btn_Pok:
			onClickPtintOk();
			break;
		default:
			break;
		}
	}

	private void onClickPtintOk() {
		// TODO Auto-generated method stub
		System.out.println("on clik print dailog ok");
		if (etTicketNo.getText().toString().length() == 0) {
			etTicketNo.setError(context.getResources().getString(
					R.string.pleasevalidTIN));
		} else {
			dismiss();

			Intent ticketIntent = new Intent(context,
					TicketBookingSummaryScreen.class);
			ticketIntent.putExtra("TAG", "PrintTicket");
			ticketIntent.putExtra("TicketNo", etTicketNo.getText().toString()
					.trim());
			((Activity) context).startActivity(ticketIntent);
		}
	}

}
